package play.go.rule;

public class SmartGameFormat {
    // pass
    public static String format(int color) {
        return ";" + (color == Color.B ? 'B' : 'W') + "[tt]";
    }

    public static String format(int color, int x, int y) {
        char cx = (char) ('a' + x - 1);
        char cy = (char) ('a' + y - 1);
        return ";" + (color == Color.B ? 'B' : 'W') + "[" + cx + cy + "]";
    }

    public static int[] parse(String sgf) {
        if (sgf.startsWith(";")) sgf = sgf.substring(1);
        int[] result = new int[3];
        result[0] = (sgf.charAt(0) == 'B') ? Color.B : Color.W;
        result[1] = (sgf.charAt(2) - 'a' + 1);
        result[2] = (sgf.charAt(3) - 'a' + 1);
        return result;
    }
}
